package com.magic.gre.mvp.model;

import com.magic.gre.Api;
import com.magic.gre.mvp.contract.WordsDetailsContract;
import com.noname.lib_base_java.mvp.BaseModelImpl;
import com.noname.lib_base_java.net.RtManager;

import io.reactivex.Observable;
import io.reactivex.Observer;
import okhttp3.ResponseBody;

/**
 * Author: Lmoumou
 * Date: 2019-01-08 11:53
 * 文件名: WordsDetailsModelImpl
 * 描述:
 */
public class WordsDetailsModelImpl extends BaseModelImpl implements WordsDetailsContract.Model {
    @Override
    public void mUnitDetails(Observer<ResponseBody> observer, String unitId) {
        Observable<ResponseBody> observable = RtManager.getInatance().createApi(Api.class).unitDetails(unitId);
        doHttp(observer, observable);
    }

    @Override
    public void mNewWordsSave(Observer<ResponseBody> observer, String vocabularyId) {
        Observable<ResponseBody> observable = RtManager.getInatance().createApi(Api.class).unripeSave(vocabularyId);
        doHttp(observer, observable);
    }

    @Override
    public void mRipeWordsSave(Observer<ResponseBody> observer, String vocabularyId) {
        Observable<ResponseBody> observable = RtManager.getInatance().createApi(Api.class).cookedSave(vocabularyId);
        doHttp(observer, observable);
    }

    @Override
    public void mRecordSave(Observer<ResponseBody> observer, String id, String unitId) {
        Observable<ResponseBody> observable = RtManager.getInatance().createApi(Api.class).recordSave(id, unitId);
        doHttp(observer, observable);
    }

    @Override
    public void mCountToDay(Observer<ResponseBody> observer) {
        Observable<ResponseBody> observable = RtManager.getInatance().createApi(Api.class).countToday();
        doHttp(observer, observable);
    }

    @Override
    public void mLearnRecordUpdate(Observer<ResponseBody> observer, String id) {
        Observable<ResponseBody> observable = RtManager.getInatance().createApi(Api.class).learnRecordUpdate(id);
        doHttp(observer, observable);
    }

    @Override
    public void mCreat(Observer<ResponseBody> observer) {
        Observable<ResponseBody> observable = RtManager.getInatance().createApi(Api.class).create();
        doHttp(observer, observable);
    }

    @Override
    public void mLastUnit(Observer<ResponseBody> observer, String unitId) {
        Observable<ResponseBody> observable = RtManager.getInatance().createApi(Api.class).lastUnit(unitId);
        doHttp(observer, observable);
    }
}
